package com.itheima.mapper;

import com.itheima.domain.Person;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/*
    使用注解方式实现映射
 */
public interface PersonMapper {

    @Select("select * from person")
    List<Person> findAll();

    //添加操作
    @Insert("insert into person values(null, #{name}, #{age})")
    Integer insert(Person p);

    //修改操作
    @Update("update person set name=#{name},age=#{age} where id=#{id}")
    Integer update(Person p);

    //删除操作
    @Delete("delete from person where id=#{id}")
    Integer delete(Integer id);
}
